using System;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
using PlacementManager;
using AjaxControlToolkit;


/// <summary>
/// Summary description for VenueService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class VenueService : System.Web.Services.WebService {

    public VenueService () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    /// <summary>
    /// Returns an array of venues that begin with specific letters. This is used in an AJAX autosuggest control.
    /// </summary>
    /// <param name="prefixText">The starting letters of the location.</param>
    /// <param name="count">The number of results to return.</param>
    /// <returns></returns>
    [WebMethod]
    public string[] GetVenues(string prefixText, int count)
    {
        if (count == 0)
        {
            count = 10;
        }


        //Get a string list to return
        List<string> items = new List<string>(count);


        PlacementManager.DAL.Venue_DAL oDALVenue = new PlacementManager.DAL.Venue_DAL();
        DataSet ds = oDALVenue.SelectAllActiveStartingWith(prefixText);
        //Loop through the locations list and add the first x number to the string list
        int i = 0;
        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            items.Add(dr["VenueName"].ToString());
            i++;
            if (i > count)
            {
                break;
            }
        }


        return items.ToArray();
    }
    
}

